package com.zliuyno.rpcdemo.rpc.Protocol;

import java.io.Serializable;
import java.util.UUID;

public class MyHeader implements Serializable {
    //通信上的协议
    /**
     * 1.ooxx值
     * 2.UUID
     * 3.DATA_LEN
     */
    int flag;   //32bit可以设置很多信息
    long requestID;
    long dataLen;

    public static MyHeader createHeader(byte[] msg) {
        MyHeader header = new MyHeader();
        int size = msg.length;
        int f = 0x14141414;
        long requestID = Math.abs(UUID.randomUUID().getLeastSignificantBits());
        header.setFlag(f);
        header.setDataLen(size);
        header.setRequestID(requestID);
        return header;
    }

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    public long getRequestID() {
        return requestID;
    }

    public void setRequestID(long requestID) {
        this.requestID = requestID;
    }

    public long getDataLen() {
        return dataLen;
    }

    public void setDataLen(long dataLen) {
        this.dataLen = dataLen;
    }
}